<? 
require 'config.php';
$domain = 'http://massseo.vn';
$sitemap = '';
$sitemap .= '<url>
                <loc>'.$domain.'</loc>
                <changefreq>Hourly</changefreq>
                <priority>1.00</priority>
              </url>';
// Sản phẩm
$sitemap .= '<url>';
$sitemap .= '<loc>'.$domain.'/san-pham'.'</loc>';
$sitemap .= '<changefreq>Daily</changefreq>';
$sitemap .= '<priority>0.80</priority>';
$sitemap .= '</url>';
//các category
$db_menu = new db_query('SELECT cat_id,cat_type,cat_name 
                        FROM categories_multi
                        WHERE cat_type= "tutorial" AND cat_parent_id != 0
                        LIMIT 10');
$list_cat = $db_menu->resultArray();unset($db_menu);
foreach($list_cat as $cat){
    $sitemap .= '<url>';
    $sitemap .= '<loc>'.$domain.'/huong-dan/'.removeTitle($cat['cat_name']).'/</loc>';
    $sitemap .= '<changefreq>Hourly</changefreq>';
    $sitemap .= '<priority>0.80</priority>';
    $sitemap .= '</url>';
}
//sitemap  
$sitemap .= '<url>';
$sitemap .= '<loc>'.$domain.'/sitemap.xml'.'</loc>';
$sitemap .= '<changefreq>Daily</changefreq>';
$sitemap .= '<priority>0.80</priority>';
$sitemap .= '</url>';
//tags  
$sitemap .= '<url>';
$sitemap .= '<loc>'.$domain.'/tags/'.'</loc>';
$sitemap .= '<changefreq>Weekly</changefreq>';
$sitemap .= '<priority>0.80</priority>';
$sitemap .= '</url>';
//list bài mới
$db_query = new db_query('SELECT tut_id,tut_title,tut_date,
                                    tut_cat_id,cat_id,cat_name
                                FROM tutorials 
                                LEFT JOIN categories_multi ON cat_id = tut_cat_id 
                                WHERE 1
                                ORDER BY tut_date DESC 
                                LIMIT 30');
$list_news = $db_query->resultArray();unset($db_query);
foreach($list_news as $news){
    $sitemap .= '<url>';
    $sitemap .= '<loc>'.$domain.generate_tutorials_detail_url($news).'</loc>';
    $sitemap .= '<changefreq>Weekly</changefreq>';
    $sitemap .= '<priority>0.64</priority>';
    $sitemap .= '</url>';
}
ob_clean();
?>
<?header ("Content-Type:text/xml");?>
<?php 
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<urlset
      xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
            http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<?=$sitemap?>
</urlset>
